package com.ygq.manageGame.util;

/**
 * 返回json的工具类
 * @param <T>
 */
public class Result<T> {
    private int code;
    private String Msg;
    private T data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return Msg;
    }

    public void setMsg(String msg) {
        Msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Result() {
    }

    public Result(T data) {
        this.data = data;
    }
    public static Result success(){
        Result result = new Result<>();
        result.setCode(200);
        result.setMsg("成功");
         return result;
    }
    public static <T> Result<T> success(T data){
        Result<T> tResult = new Result<>(data);
        tResult.setMsg("成功");
        tResult.setCode(200);
        return tResult;
    }
    public static Result error(int code,String msg){
        Result result = new Result<>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static <T> Result<T> error(int code,String msg,T data){
        Result<T> tResult = new Result<>(data);
        tResult.setCode(code);
        tResult.setMsg(msg);
        return tResult;
    }
}
